package com.qf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.mapper.ShopMapper;
import com.qf.pojo.Shop;
import com.qf.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 针对商品的业务接口实现层
 */
@Service
public class ShopServiceImpl implements ShopService {
    //注入Mapper
    @Autowired
    private ShopMapper shopMapper;
    @Override
    public List<Shop> findAll(Integer page, Integer size) {
        //设置分页
        PageHelper.startPage(page,size);
        List<Shop> list = shopMapper.selectAll();
        //分页实体的组件
        PageInfo pageInfo  = new PageInfo(list);
        System.out.println(pageInfo);
        return list;
    }

    @Override
    public void addShop(Shop shop) {
        System.out.println("添加商品执行了...");
        shopMapper.addShop(shop);
    }

    @Override
    public void deleteShop(int id) {
        System.out.println("删除商品执行了...");
        shopMapper.deleteShop(4);

    }

    @Override
    public void updateShop(Shop shop) {
        System.out.println("更新商品执行了");
        shopMapper.updateShop(shop);
    }

    @Override
    public void selectShop(Shop shop) {
        System.out.println("查询商品执行了");
        shopMapper.selectShop(shop);
    }
}
